package com.qfedu.mapper;

import com.qfedu.model.Contractor;
import com.qfedu.model.Developer;
import com.qfedu.model.Project;
import com.qfedu.model.Subitem;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @author LiJH
 * @date 2023-02-10
 */
public interface SubitemMapper {
    @Select("select count(*) from subitem where status=1")
    long count();
    @Select("select * from subitem where status=1 limit #{currentPage},#{pageSize}")
    List<Subitem> findPage(@Param("currentPage") Integer currentPage, @Param("pageSize") Integer pageSize);

    @Insert("insert into subitem(suid,sname,starttime,endtime,pid,updatetime)" +
            " values(#{suid},#{sname},#{starttime},#{endtime},#{pid},#{updatetime}) ")
    int addSubitem(Subitem subitem);

    @Select("select * from subitem where suid=#{suid} and status=1 ")
    Subitem findById(String suid);
    @Select("select * from subitem where pid=#{pid} and status=1 ")
    List<Subitem> findByPid(int pid);

    @Update("update subitem set sname=#{sname},starttime=#{starttime},endtime=#{endtime}," +
            "pid=#{pid},updatetime=#{updatetime} where suid=#{suid}")
    int editSubitem(Subitem subitem);

    //删除
    @Update("update subitem set status=0 where suid = #{suid}")
    int deleteBySuid(String suid);
}
